<?php 

class InsertMeasurement_Model extends CI_Model
{
    function __construct() 
    {
           parent::__construct();
    }
    
    function insertMeasurement($data)
    {
        $this->db->insert('LECTURA',$data);
    }
    
    function validMeasurement($measurement,$serial)
    {
        $query ="SELECT CON_CAPACIDAD  FROM CONTADOR WHERE CON_SERIAL =".$serial;
        $result_counter= $this->db->query($query)->result();
        
        foreach ($result_counter as $row)
        {
            if($row->CON_CAPACIDAD>$measurement && $measurement>=0){
                return true;
            }
            return false;            
        }
        return false;
    }
}

?>